<%@page import="net.sf.json.JSONNull"%>
<%@page import="com.yunhuakeji.wddx.utils.IsNull"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>目标广场</title>
     <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/Yhmain.css">
    <link rel="stylesheet" href="css/window.css" />
    <link href="css/pl.css" rel="stylesheet" type="text/css">
	<script src="js/jquery.min.js"></script>
	<script src="js/echarts.min.js" type="text/javascript"></script>
	<script src="js/myReport.js"></script>
	<script src="js/bqbApp.js"></script> 
    <script src="js/window.js"></script>
  </head>
  <style> 
  	body {
	    font-family:"Arial","Microsoft Yahei","sans-serif";
	    background-color: #f2f2f2;
	    min-width:20em;
	    font-size:14px;
   }
   .ft10{
        margin-left:-1.7em;
       -webkit-transform:scale(0.8);
   }
   .Input_Box{
        margin-top:0px;
   }
   div:focus{
        border:0px;
   }
 .ios_fixed_main{
        position:absolute;
        width:100%;
        top:0;
        bottom:1px;
        overflow-y: scroll;
        /* 增加该属性，可以增加弹性，是滑动更加顺畅 */
        -webkit-overflow-scrolling: touch; 
   }
   .ios_fixed_footer{
        position:absolute;
        width:100%;
        bottom:0;
        display:none;
   }
  </style>
  <body style="background:#eeeeee;" >
   <div class="ios_fixed_main">
      <div class="square_head">
          <span><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1490874013858&di=4ba5685294a90a875171097f6403d1d7&imgtype=0&src=http%3A%2F%2Fv1.qzone.cc%2Favatar%2F201408%2F03%2F23%2F44%2F53de58e5da74c247.jpg%2521200x200.jpg"/></span>
          <a>王小宇</a>
      </div>
      <div class="mt10 square_content">
	       <div id="the_share_square">
	       </div>
      </div> 
   </div>
   <div class="ios_fixed_footer">
      <div id="input_boxxx"  class="Input_Box" style="border-color: rgb(204, 204, 204);height:60px;background:#EaEbed;padding-bottom:20px;position:fixed;bottom:0;display:none;"> 
		  <div style="display:block;position:relative;">
		      <div class="Input_Foot" style="background:#EaEbed;"> 
			      <a class="imgBtn" href="javascript:void(0);">
			      </a>
		      </div>
	      </div>
		  <a contenteditable="true" class="Input_text" style="max-height:60px;height:20px;width:calc(75% - 1.5em - 2px);display:inline-block;border:1px solid #cccccc;border-radius:5px;margin-left:.5em;background:#fefefe;"></a>
		  <a class="postBtn" onmouseover="onmous1(this)" onmouseout="onmousout1(this)" style="height:16px;width:calc(25% - 10px - 2.5em);margin:0em 1.25em;display:inline-block;background:#fefefe;">发送</a> 
      </div> 
      <div id="input_boxff" class="Input_Box" style="border-color: rgb(204, 204, 204);background:#EaEbed;padding-bottom:20px;position:fixed;bottom:0;display:none;">
          <div style="display:block;position:relative;">
             <div class="Input_Foot" style="background:#EaEbed;"> 
                <a class="imgBtn" href="javascript:void(0);"></a>
             </div>
	      </div>
		  <a contenteditable="true" class="Input_text" style="height:20px;width:calc(75% - 1.5em - 2px);display:inline-block;border:1px solid #cccccc;border-radius:5px;margin-left:.5em;background:#fefefe;"></a>
		  <a class="postBtn" onmouseover="onmous1(this)" onmouseout="onmousout1(this)" style="height:16px;width:calc(25% - 10px - 2.5em);margin:0em 1.25em;display:inline-block;background:#fefefe;">发送</a> 
	      <div class="faceDivApp"></div>
      </div>
   </div>
      <!--   删除评论框 -->
      <div>
         <div class="modal" id="mymodal">
         	<div class="scpl">
         	   <a class="color-red" href="javascript:deletePl();">删除</a>
               <a class="mt10" href="javascript:hideModal();">取消</a>
         	</div>
         </div>
      </div>

  <script>
var page = 1;
var gPageSize = 10; 
var total_share_targets;
var user_id = '<%=request.getParameter("userid")%>';
var user_name = '<%=request.getParameter("username")%>';
var faceaddress = '<%=request.getParameter("faceaddress")%>';
var ticket = '<%=request.getParameter("ticket")%>';
var lastTime=0;
var timeout=0;
//评论参数
var _mbid;
var $the_dom;
var the_a_id;
var s_id;
var a_name;
var pllbid;
var del_id;
var del_a_id;
var del_com_id;
var delsta;
$('body').append(' <input id="user_id" style="display:none" value="'+user_id+'"  />');
$('form[name="userid_form"] input:hidden').attr('value',user_id);
var user_img='';
var user_name='';
$.getJSON('/WDDXSERVER/targetsquare/getShareNumberApp',{userid:user_id,ticket:ticket},function(data){
	data = data[0].content.message;
	total_share_targets=data[0].total;
	user_img=data[0].url;
	user_name=data[0].name;
	$('#user_img').attr('src',data[0].url);
	$('div#btn div.the_user_name').text(data[0].name);
	$('div#btn ul li:eq(0) a').text('我的分享 （'+data[0].count+'）');
	$('div#btn ul li:eq(1) a').text('我的积分 （'+data[0].number+'）');
	 my_square("/WDDXSERVER/targetsquare/getShareInfoApp",{userid:user_id,cxtj:'',pageSize:gPageSize,pagenum:page,ticket:ticket});
});

$('input.search_input_button').click(function(){
	   $('div#the_share_square').empty();
	   page=1;
	   my_square('/WDDXSERVER/targetsquare/getShareInfoApp',{userid:user_id,cxtj:encodeURI($(this).prev().val()),pageSize:gPageSize,pagenum:page,ticket:ticket});
	   
});

//删除评论
function deletePl(){
	var url;
 	if(delsta){
 		url='/WDDXSERVER/targetsquare/deleteCommentsApp?s_id='+del_id;
	}else{
		url='/WDDXSERVER/targetsquare/deleteReplyApp?s_id='+del_id;
	}
	$.ajax({
		url:url,
		type:'post',
		dataType:'json',
		data:{"com_id":del_com_id,"a_id":del_a_id,ticket:ticket,userid:user_id},
		success:function(data){
			if(data["code"]=='40001'){
				$(removeDom).remove();
			}
			if(delsta){
				$('a[data-id='+delsta+']').parent().parent().remove();
			}
		}
	});
}
var removeDom;
function getNowTime(a){
	var nowtime = new Date().getTime();
	var time =nowtime - a ;
	if(time>1500){
		$(removeDom).removeClass("bg-color-gray1");
		$('#mymodal').parent().addClass("show-modal");
	}
	return false;
}
var removeDom;
function removeC(){
	$(removeDom).removeClass("bg-color-gray1");
}
function get_comments(s_id){
	//跨域取数据
	$.getJSON("/WDDXSERVER/targetsquare/getCommentApp?userid="+user_id+"&s_id="+s_id+'&ticket='+ticket,function(data,status,xhr){
		var dom = $('#pllb_'+s_id);
	//绑定数据
		var htmlroot = null;
		data = data.content.message;
		$.each(data,function(index,rec){
		if(rec["bjzd"] == 0){
		   var Reply= rec["a_content"];
		   	dom.append(htmlroot);	
			htmlroot = null;
			htmlroot = '<div plzt="'+rec["operate"]+'" class="text-left mb3 huif">'	
			                			+'<div class="ml3">'+'<a href="javascript:;" data-id="'+rec["com_id"]+'" data-comment="'+rec["a_id"]+'">'+rec["a_answer_name"]+'</a>'+"："+Reply+'</div>'
		                	+'</div>'
		 }else{
			 var Reply= rec["a_content"];
			 dom.append(htmlroot);	
		     htmlroot = null;
			 htmlroot = '<div plzt="'+rec["operate"]+'" class="text-left mb3 huif">'
					 			 +'<div class="ml3">'
					 			   +'<a href="javascript:;" data-id="'+rec["com_id"]+'" data-comment="'+rec["a_id"]+'" >'+rec["a_answer_name"]+'</a>'
					 			   +'<span class="color-black">'+"&nbsp&nbsp回复&nbsp&nbsp"+'<span>'
					 			   +'<a href="javascript:;">'+rec["a_be_answer_name"]+'</a>'+"："+Reply
					 			 +'</div>'
						   +'</div>'
		 }
		});
		dom.append(htmlroot);
		$('div.huif').unbind('click').bind('click',function(){
			var _this = $(this);
			delsta = null;
			_mbid = _this.parent().parent().parent().attr("data-id");
		 	event.stopPropagation(); 
		 	if($(_this).attr("plzt")==1){
		 		if(_this.children().children().attr("data-id")!=_this.prev().children().children().attr("data-id")){
		 			delsta= _this.children().children().attr("data-id"); 
		 		}
		 		del_id = _this.parent().parent().parent().attr("data-id");
		 		del_com_id = _this.children().find('a').attr("data-id");
		 		del_a_id = _this.children().find('a').attr("data-comment");
		 		$('.ios_fixed_footer').css("display","none");
		 		$('#input_boxxx').css("display","none");
		 		$('#mymodal').parent().addClass("show-modal");
		 		return false;
		 	}
			$the_dom = _this;
			a_name = _this.children().find('a:eq(0)').text();
			the_a_id = $(this).children().children().attr("data-comment");
			s_id = $(this).children().children().attr("data-id");
			$('#input_boxxx a.Input_text').empty().append("<span style='color:#eeeeee;'>"+"回复："+a_name+"</span>");
			$('.ios_fixed_footer').css("display","block");
			$('#input_boxxx').css("display","block");
			document.body.scrollTop = document.body.scrollHeight;
		    $('#input_boxxx a.Input_text').focus();
			//绑定键盘事件，清除placehodler
			 $('#input_boxxx a.Input_text').unbind('keydown').keydown(function(){
			     $(this).empty();
			     $(this).unbind('keydown');
			 });
		}); 
		
		$('div.huif').unbind('touchstart').on("touchstart", function (event) {
			var _this = $(this);
			delsta = null;
			_mbid = _this.parent().parent().parent().attr("data-id");
			del_id = _this.parent().parent().parent().attr("data-id");
	 		del_com_id = _this.children().find('a').attr("data-id");
	 		del_a_id = _this.children().find('a').attr("data-comment");
			_this.addClass("bg-color-gray1");
			lastTime=new Date().getTime();
			removeDom = _this;
			timeout= setTimeout("getNowTime("+lastTime+");",1500);
			if(_this.children().children().attr("data-id")!=_this.prev().children().children().attr("data-id")){
	 			delsta= _this.children().children().attr("data-id"); 
	 		}
		});
		
		 $('div.huif').unbind('touchend').on('touchend',function(){
			event.stopPropagation(); 
			$(this).removeClass("bg-color-gray1");
			clearTimeout(timeout);  
		}); 
		comment_control(s_id);
	});
	
};
function my_square(url,param){
	page++;
	var dom;
$.getJSON(url,param,function(data,status,xhr){
	 $(".loaddiv").show();  
	 data = data.content.message;
	if(status=='success'&&data.length>0){
	  for(var i=0;i<data.length;i++){
		  var the_status='';
		  var the_operate='';
		  if(data[i].state=='0')
			  the_status='点赞';
		  else
			  the_status='取消赞'	; 
		  if(data[i].operate=='1')
			  the_operate='加入我的目标';
		  else
			  the_operate='已加入目标'	; 
		  var str='';
		 str+='<div name="onejl" data-id="'+data[i].id+'" data-target="'+data[i].t_id+'">'+
		  '<div style="border:1px #cbc7c7 solid;" class="pd10">'+
		  	'<div><div class="header-photo_app bg-color-gray float-l" >'+
		  	   '<img src="'+data[i].path+'" width="100%" height="100%"/></div>'+
		  		'<div class="float-l ml5 text-left">'+
		  			'<a class="font-size-h3">'+data[i].s_user+'</a>'+
		  			'<div class="in-block color-gray-word ft10">'+
		  			  '<a>'+data[i].s_date+'</a>'+'<span class="ml10">'+data[i].mbtype+
		  			 '</span><a href="#"><img src="img/liulan_03.png" alt="" class="ml20" height="14px;"/></a><a style="margin-left:4px;">浏览   ('+data[i].browse+')</a></div>'+
		  		'</div></div><div class="pt10 clear-b text-left"><a>'+data[i].title+'</a></div>'+
		  	   '<div class="text-left border-all pd10 bg-color-qyellow"><div class="font-size-h3">'+data[i].mbtitle+'</div>'+
		  		'<a class="block pt5">描述：'+data[i].ms+'</a><a class="block pt5 color-blue" href="javascript:" name="showAll">展开全部</a>'+
		  		'<div class="pt5" ><a class="block float-l pr10">展开任务分解</a><img name="qh" src="img/sanjiao_03.png" height="19px;" style="float:left;"/><div class="clear-b"></div></div>'+
		  		'<table name="table_'+data[i].id+'" class="mt20 my-table " width="100%">'+
		  		'<tbody><tr><td>序号</td><td>描述</td><td>相关资料</td><td>签到次数</td></tr></tbody></table></div><div class="clear-b"></div></div>'+

		  		 '<div class="text-left plcz myplcz" >'+
		  	     '<a class="block pd10-plr20 float-l" name="pinglun" href="div[name=main-pl]"><div class="img">'+
		  	     '<img src="img/pinlun_03.png" height=100%/></div>评论</a>'+
		  	     '<a class="block pd10-plr20 float-l"  name="pinglun" href="#" ><div class="img"><img src="img/dianzan_03.png" height=100%/>'+
		  		 '</div><span name="dianzan" data-operate="'+data[i].state+'">'+the_status+'('+data[i].zan+')</span></a>'+
		  	     '<div class="clear-b"></div>'+
		  	    
		  	    '</div><div class="pd5 border-all bg-color-qyellow text-right" style="padding-top:0px;">'+
		  			'<div class="text-left mb10 mt10 dianzan_object" name="dianzan_object_'+data[i].id+'"><img src="img/mbgc_11.png" class="zan_sign" ></div>'+
		             '<div id="pllb_'+data[i].id+'" style="margin-top:0.5em"></div> <div class="Input_Box" name="main-pl"> <div contenteditable="true" class="Input_text"></div><div style="display:none;" id="btnpl">'+
		  	      	 '<div class="faceDiv"> </div>'+
		  	      	 '<div class="Input_Foot"> <a onmouseover="onmous1(this)" onmouseout="onmousout1(this)" class="imgBtn" href="javascript:void(0);"></a><a class="postBtn" onmouseover="onmous1(this)" onmouseout="onmousout1(this)">确定</a> </div></div></div></div></div>';
		  	      	 $('div#the_share_square').append(str);
		  	      	 for(var j=0;j<data[i].table.length;j++)
		  	          	$('table[name="table_'+data[i].id+'"] tbody').append('<tr><td>'+data[i].table[j].c_id+'</td><td>'+data[i].table[j].c_name+'</td><td>'+data[i].table[j].c_resource+'</td><td>'+data[i].table[j].c_daynum+'</td></tr>');
		  	      	 $('a[name=showAll]').unbind('click').bind('click',function(){
		  	  		   var url1 = "img/sanjiao_01.png";
		  	  		   var url2 = "img/sanjiao_03.png";
		  	  		   if($('table').css("display")=="none"){
		  	  			 $('img[name=qh]').attr("src",url2); 
		  	  		   }else{
		  	  		 	$('img[name=qh]').attr("src",url1);  
		  	  		    }
		  	  		     $(this).siblings('table').toggle();
		  	         });
		  	      	$(' a[name="menubt"]').unbind('click').bind('click',function(){
		  	      		var the_share_id=$(this).parents('div[name=onejl]').attr('data-id');
		  				$(this).next().toggle();
		  				$(this).next().find('li:eq(0)').click(function(){
		  					 $(this).parent().hide('fast');
		  					$(this).parents('div[name=onejl]').hide('slow');
		  				   
		  				});
		  				$(this).next().find('li:eq(1)').click(function(){
		  					$('div#review_dialog input[type="text"]').val('');
		  					$('div#review_dialog ').show('fast');
		  					$(this).parent().hide('fast');
		  					$('div#review_dialog i.fa-times,div#review_dialog button.cancle_it').click(function(){
		  						$('div#review_dialog ').hide('fast');
		  					});
		  					$('div#review_dialog input[name=report_input]').change(function(){
		  						  $('div#review_dialog button.do_it').prev().hide('fast');
		  					});
		  					$('div#review_dialog button.do_it').click(function(){
		  						var the_report_reason1=encodeURI($('div#review_dialog input[name="report_input"]:checked').attr('value'));
		  						var the_report_reason2='';
		  						the_report_reason2=encodeURI($('div#review_dialog input[type="text"]').val());
		  						if(typeof(the_report_reason1)=='undefined')
		  							$(this).prev().show('fast');
		  						else{
		  							$(this).prev().hide('fast');
		  							$.getJSON("/WDDXSERVER/targetsquare/whistle_blowing",{userid:user_id,s_id:the_share_id,content:the_report_reason1,describe:the_report_reason2},function(data){
		  								if(data.message=='成功'){
		  									 win.alertApp("系统通知","举报成功，我们会以消息方式提醒您处理结果。");
				  							 $('div#review_dialog ').hide('fast');
		  								}
		  							});
		  						   
		  						}
		  					});
		  				});
		  	     	});
		 	   $('div[name=main-pl] div.Input_text').unbind('click').bind('click',function(event){
		 		   event.stopPropagation(); 
		 		   var _this = $(this);
		 		   _mbid = _this.parent().parent().parent().attr("data-id");
		 		   pllbid = _this.parent().prev();
		 		   $the_dom = "";
		 		   $('html, body').animate({  
	                    scrollTop: $(_this).parent().parent().parent().offset().top/* +document.body.clientWidth */
	                }, 0);
		 		   _this.blur();
		 		   if($("#input_boxxx").css("display") == "none"){
		 			  $('.ios_fixed_footer').css("display","block");
		 			  $("#input_boxxx").css("display","block");
		 		   }
		 		   $("#input_boxxx a.Input_text").empty();
		 		   document.body.scrollTop = document.body.scrollHeight;
		 		   $("#input_boxxx a.Input_text").focus();
		 	   });
		  	   $('a[name=pinglun]').unbind('click').bind('click',function(event){
		  		 if($(this).text()=='评论'){
		  			  _mbid = $(this).parent().parent().attr("data-id");
		  			  pllbid = $(this).parent().next().find('div:eq(1)');
		  			  $the_dom = "";
		  			  $('.ios_fixed_footer').css("display","block");
		  			  $("#input_boxxx").css("display","block");
		  			  $("#input_boxxx").find("a.Input_text").empty();
		  			document.body.scrollTop = document.body.scrollHeight;
		  			  $("#input_boxxx").find("a.Input_text").focus();
		  		   }
		  		 else if($(this).find('span').attr('name')=='dianzan'){
		  			 var id=$(this).parent().parent().attr('data-id');
		  			 var $the_target=$(this);
		  			 if($(this).find('span').attr('data-operate')=='0'){
			  				$.ajax({
			  					url:'/WDDXSERVER/targetsquare/thumbsUpShare',
			  				    data:{userid:user_id,s_id:id,state:'1',ticket:ticket},
			  				    type:'post'
			  				}).done(function(data){
			  					    data = data.content; 
			  						if(data.message){
			  							$the_target.find('span').text('取消赞 ('+(parseInt($the_target.find('span').text().match(/\d+/g))+1)+')');
			  							$the_target.find('span').attr('data-operate','1');
					  			        var $the_id_dom=$the_target.parents('div[name=onejl]');
					  			      $('div[name=dianzan_object_'+$the_id_dom.attr('data-id')+']').css('display','block');
					  			      $('div[name=dianzan_object_'+$the_id_dom.attr('data-id')+'] img.zan_sign').after('<img data-bz="myself_dianzan" src="'+user_img+'" >');
					  			      if(parseInt($the_target.find('span').text().match(/\d+/g))>6)
						  				 $('div[name=dianzan_object_'+$the_id_dom.attr('data-id')+'] span').text('共'+parseInt($the_target.find('span').text().match(/\d+/g))+'人点赞');
			  						}
			  						else
			  						   win.alertApp('系统提醒','失败，请稍后操作');
			  				});
			  			    
			  			 }
			  			 else{
			  				
			  				$.ajax({
			  					url:'/WDDXSERVER/targetsquare/thumbsUpShare',
			  				    data:{userid:user_id,s_id:id,state:'-1',ticket:ticket},
			  				    type:'post'
			  				}).done(function(data){
			  					data = data.content; 
			  					if(data.message){
			  						$the_target.find('span').text('点赞 ('+(parseInt($the_target.find('span').text().match(/\d+/g))-1)+')');
			  				       $the_target.find('span').attr('data-operate','0');
			  				       if(parseInt($the_target.find('span').text().match(/\d+/g))==0)
				  				     $('div[name=dianzan_object_'+$the_target.parents('div[name=onejl]').attr('data-id')+']').css('display','none');
			  				       if(parseInt($the_target.find('span').text().match(/\d+/g))>6)
				  				      $('div[name=dianzan_object_'+$the_target.parents('div[name=onejl]').attr('data-id')+'] span').text('共'+parseInt($the_target.find('span').text().match(/\d+/g))+'人点赞');
			  				       $('div[name=dianzan_object_'+$the_target.parents('div[name=onejl]').attr('data-id')+'] img[data-bz=myself_dianzan]').remove();
			  					}else
			  						   win.alertApp('系统提醒','失败，请稍后操作');
			  					});
			  			 }
		  		  }
		  		/*  else {
		  			var $this_a=$(this).find('span:contains(加入我的目标)');
	  				$.ajax({
	  					url:'/WDDXSERVER/target/addTargetfromSquare',
	  					data:{userid:user_id,targetID:$(this).parents('div[name=onejl]').attr('data-target')}
	  				}).done(function(data){
			  			 win.alertApp("系统提示","已成功添加日常目标！");
			  			 setTimeout(function(){
			  				$('div.win').css('display','none');
			  				$this_a.text('已加入目标');
			  				
			  				$this_a.parents('a[name=pinglun]').unbind('click').bind('click',function(){
			  				   $(this).css({'cursor':'default'});
			  				   return false;	
			  				});
			  			},1000);
	  				});	
		  		 } */
		  		return false;
		  	});
		  	 if(data[i].zan>0)
		  	    get_dianzan(data[i].id);
		  	 else if(data[i].zan==0)
		  		$('div[name=dianzan_object_'+data[i].id+']').css('display','none');
		  	 get_comments(data[i].id);
	  }
	 
	}
});
};
 function get_dianzan(param){
	  $.ajax({
			url:'/WDDXSERVER/targetsquare/getThumbsUp',
		    data:{userid:user_id,s_id:param,ticket:ticket},
		    type:'post'
		 }).done(function(data){
			 for(var m=0;m<data.length;m++){
  	      		 if(m<=6 && data[m].bs =='1')
  	      			$('div[name=dianzan_object_'+param+']').append('<img data-bz="myself_dianzan" src="'+data[m].path+'" >');
  	      		 else if(m<=6 && data[m].bs =='0')
	      			$('div[name=dianzan_object_'+param+']').append('<img src="'+data[m].path+'" >');
  	      		 else{
  	      			$('div[name=dianzan_object_'+param+']').append('<span>共'+data.length+'人点赞</span>'); 
  	      		    break;	
  	      		 }
  	      	 } 
		 });
 }
 function operate_zan(param){
      $.ajax({
		url:'/WDDXSERVER/targetsquare/thumbsUpShare',
	    data:param,
	    type:'post'
	}).done(function(data){
			return data[0].message;	 
	});
}
function onmous(a){
	$(a).addClass("active");
}
function onmousout(a){
	$(a).removeClass("active");
}
function onmous1(a){
	$(a).addClass("active1");
}
function onmousout1(a){
	$(a).removeClass("active1");
}

function comment_control(s_id){
	  $("a[name=p1]").unbind('click').bind('click',function(){
		 event.stopPropagation(); 
		 the_a_id = $(this).parent().prev().find('a').attr("data-comment");
		 s_id = $(this).parent().prev().find('a').attr("data-id");
		 $the_dom = $(this).parent().parent();
		 a_name = $(this).parent().prev().find('a').text();
		 $('#input_boxxx').css("display","block");
		 $('#input_boxxx').find('a.Input_text').html("<span style='color:#eeeeee;'>"+"回复："+$(this).parent().prev().find('a').text()+"</span>");
		 $('#input_boxxx').find('a.Input_text').focus();
		 //绑定键盘事件，清除placehodler
		 $('#input_boxxx a.Input_text').unbind('keydown').keydown(function(){
		     $(this).empty();
		     $(this).unbind('keydown');
		 });
	});
	  $("a.comment_delete").unbind('click').bind('click',function(){
		  var the_comment='';
		  //回复id；
		  the_comment=$(this).parent().prev().find('a').attr('data-comment');
		  //分享id
		  var the_s_id=$(this).parents('div[name=onejl]').attr('data-id');
			if($(this).parent().parent().parent().attr('class')=='pt5'){
				var the_reply=$(this).parents('div.pt5').parent().prev().children('div.ml3').find('a').attr('data-id');
				$(this).parents('div.pt5').remove();
				$.getJSON("/WDDXSERVER/targetsquare/deleteReplyApp",{userid:user_id,s_id:the_s_id,com_id:the_reply,a_id:the_comment,ticket:ticket},function(data,status,xhr){
				});
				}
			else{ 
				var the_reply=$(this).parents('div.color-gary').prev().find('a').attr('data-id');
			
				$(this).parent().parent().parent().parent().remove();
				$.getJSON("/WDDXSERVER/targetsquare/deleteCommentsApp",{userid:user_id,s_id:the_s_id,com_id:the_reply,ticket:ticket},function(data,status,xhr){
				});	
			}
		});
	$('div[name=annex-pl] div.Input_text').bind('blur',function(){
		$(this).focus();
		if(!$('a[name=postBTN1]').hasClass("active") && !$('a[name=imgBTN1]').hasClass("active") && !$('img').hasClass("active")){
			$(this).parent().css("display","none");
			$('div[name=main-pl]').css("display","block");
			$('div[name=main-pl] div.Input_text').css("height","20px");
		}
	});
   
};

function paint_comment(id,sign,url,param,a_name){
$.getJSON(url,param,function(data){
	var html='';
	if(data.message=='成功'){
      if(id){
    	  html+='<div plzt=1 class="text-left mb3 huif">'
	           +'<div class="ml3">'
	               +'<a href="javascript:;" data-id="'+data.content.message.com_id+'" data-comment="'+data.content.message.a_id+'">'+user_name+'</a>'+'<span class="color-black">'+"&nbsp&nbsp回复&nbsp&nbsp"+'<span>'+'<a href="javascript:;">'+a_name+'</a>'+"："+decodeURI(param.content)
	           +'</div>'
		    +'</div>';
			$(id).after(html);
			$(id).next().click(function(){
				var _this = $(this);
				delsta = null;
				_mbid = _this.parent().parent().parent().attr("data-id");
				removeDom = _this;
				_this.addClass('bg-color-gray1');
				setTimeout("removeC();",100);
				//判断是否有权限删除
			 	if($(_this).attr("plzt")==1){
			 		if(delsta){
						$('a[data-id='+delsta+']').parent().parent().remove();
					}
			 		del_id = _this.parent().parent().parent().attr("data-id");
			 		del_com_id = _this.children().find('a').attr("data-id");
			 		del_a_id = _this.children().find('a').attr("data-comment");
			 		$('.ios_fixed_footer').css("display","none");
			 		$('#input_boxxx').css("display","none");
			 		$('#mymodal').parent().addClass("show-modal");
					return false;
				} 
			 	event.stopPropagation(); 
				$the_dom = _this;
				a_name = _this.children().find('a:eq(0)').text();
				the_a_id = $(this).children().children().attr("data-comment");
				s_id = $(this).children().children().attr("data-id");
				$('#input_boxxx a.Input_text').empty().append("<span style='color:#eeeeee;'>"+"回复："+a_name+"</span>");
				$('.ios_fixed_footer').css("display","block");
				$('#input_boxxx').css("display","block");
				document.body.scrollTop = document.body.scrollHeight;
			 	$('#input_boxxx a.Input_text').focus(); 
				//绑定键盘事件，清除placehodler
				 $('#input_boxxx a.Input_text').unbind('keydown').keydown(function(){
				     $(this).empty();
				     $(this).unbind('keydown');
				 });
			});
      }else{
    	   html+='<div plzt=1 class="text-left mb3 huif">'
	           +'<div class="ml3">'
	               +'<a href="javascript:;" data-id="'+data.content.message.com_id+'" data-comment="'+data.content.message.a_id+'" >'+user_name+'</a>'+'<a href="javascript:;">'+a_name+'</a>'+"："+decodeURI(param.content)
	           +'</div>'
		    +'</div>'; 
			 $(pllbid).append(html);
			 $(pllbid).unbind('click').on('click','.huif',function(){
				 var _this = $(this);
					removeDom = _this;
					delsta = null;
					_mbid = _this.parent().parent().parent().attr("data-id");
					_this.addClass('bg-color-gray1');
					setTimeout("removeC();",100);
					//判断是否有权限删除
				 	if($(_this).attr("plzt")==1){
				 		if(delsta){
							$('a[data-id='+delsta+']').parent().parent().remove();
						}
				 		del_id = _this.parent().parent().parent().attr("data-id");
				 		del_com_id = _this.children().find('a').attr("data-id");
				 		del_a_id = _this.children().find('a').attr("data-comment");
				 		$('.ios_fixed_footer').css("display","none");
				 		$('#input_boxxx').css("display","none");
				 		$('#mymodal').parent().addClass("show-modal");
						return false;
					} 
				 	event.stopPropagation(); 
					$the_dom = _this;
					a_name = _this.children().find('a:eq(0)').text();
					the_a_id = $(this).children().children().attr("data-comment");
					s_id = $(this).children().children().attr("data-id");
					$('#input_boxxx a.Input_text').empty().append("<span style='color:#eeeeee;'>"+"回复："+a_name+"</span>");
					$('.ios_fixed_footer').css("display","block");
					$('#input_boxxx').css("display","block");
					document.body.scrollTop = document.body.scrollHeight;
					$('#input_boxxx a.Input_text').focus();
					//绑定键盘事件，清除placehodler
					 $('#input_boxxx a.Input_text').unbind('keydown').keydown(function(){
					     $(this).empty();
					     $(this).unbind('keydown');
					 });
				});
      }
      comment_control(param.param1);
      $("#input_boxxx").find("a.Input_text").blur();
	  $('.ios_fixed_footer').css("display","none");
	  $('#input_boxxx').css("display","none");
	  $('#input_boxff').css("display","none");
	}
	else
		win.alertApp("系统通知","评论失败！");
});
};
//绑定表情包
ImgIputHandler.Init();
//提交评论
$(".postBtn").unbind('touchend').bind('touchend',function(){
	event.stopPropagation();
	$(this).prev().find('span').remove('span');
	var the_comment=$(this).prev().html();
	//回复目标id
    var the_s_id=_mbid;
	//对应的节点
    var _$the_dom=$the_dom;
	//回复id
    var _the_a_id = the_a_id;
    if(the_comment){
    	if(_$the_dom){
    		paint_comment(_$the_dom,'1',"/WDDXSERVER/targetsquare/answerApp",{userid:user_id,s_id:the_s_id,a_id:the_a_id,content:encodeURI(the_comment),ticket:ticket},a_name);
    	}else{
    		paint_comment(_$the_dom,'0',"/WDDXSERVER/targetsquare/commentApp",{userid:user_id,s_id:the_s_id,content:encodeURI(the_comment),ticket:ticket},'');
    	}
	}
});
$('body').bind('touchend',function(){
	$("#input_boxxx").find("a.Input_text").blur();
	$('.ios_fixed_footer').css("display","none");
	$('#input_boxxx').css("display","none");
	$('#input_boxff').css("display","none");
	/* $('.modal').parent().removeClass("show-modal"); */
});
$('body').bind('click',function(){
	$('.modal').parent().removeClass("show-modal");
});
$('#input_boxff,#input_boxxx a.Input_text').unbind('touchend').bind('touchend',function(){
	event.stopPropagation(); 
});
function hideModal(){
	$('.modal').parent().removeClass("show-modal");
}
/* $('#input_box').bind('focus',function(){
	
}); */
  </script>
  </body>
</html>
